package cn.pku.ss.sirx.sna.ib;

import java.util.Iterator;

import cn.pku.ss.sirx.sna.ib.bean.Message;
import cn.pku.ss.sirx.sna.ib.bean.MessageBoard;
import cn.pku.ss.sirx.sna.ib.db.InfluenceDao;

/**
 * Iterator of all messages in a specified message board.
 * The messages will be iterated by date.
 *
 * @author SirX
 * @version 1.0
 */
public class MessageIterator implements Iterator<Message> {

    /**
     * Constructor.
     */
    public MessageIterator(MessageBoard messageBoard) {
        this.iterator = InfluenceDao.getInstance().
                        getMessages(messageBoard.getOwnerId()).iterator();
    }

    @Override
    public boolean hasNext() {
        return this.iterator.hasNext();
    }

    @Override
    public Message next() {
        return this.iterator.next();
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
    
    private Iterator<Message> iterator;

}
